infile=open('1E0W_neighbors')
o=open('1E0W_disjointpairs','w')
d={}
p=[]
for l in infile.readlines():
    l=l.split()
    d[int(l[0])]=l[1:]
for aa1 in d:
    for aa2 in d[aa1]:
        aa2=int(aa2)
        for aa3 in d[aa2]:
            aa3=int(aa3)
            if not (aa1==aa3 or (aa1,aa3) in p or (aa3,aa1) in p):p.append((aa1,aa3))
        if not (aa1==aa2 or (aa1,aa2) in p or (aa2,aa1) in p):p.append((aa1,aa2))
print(len(p))
print(len(d)*(len(d)-1)/2)
p.sort()
for pair in p:
    o.write(str(pair[0])+'\t'+str(pair[1])+'\n')
o.close()
